/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            accountBankManageInfo: {
                accountBanks: [],
                total: 0,
                records: 1,
                moreCondition: false,
                returnFlag: '',
                bankId: '',
                conditions: {
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            $that.accountBankManageInfo.returnFlag = vc.getParam('returnFlag');
            $that._listAccountBanks(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('accountBankManage', 'listAccountBank', function (_param) {
                $that._listAccountBanks(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listAccountBanks(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listAccountBanks: function (_page, _rows) {
                $that.accountBankManageInfo.conditions.page = _page;
                $that.accountBankManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.accountBankManageInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/accountBank/queryAccountBank',
                    param,
                    function (json, res) {
                        var _accountBankManageInfo = JSON.parse(json);
                        $that.accountBankManageInfo.total = _accountBankManageInfo.total;
                        $that.accountBankManageInfo.records = _accountBankManageInfo.records;
                        $that.accountBankManageInfo.accountBanks = _accountBankManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.accountBankManageInfo.records,
                            dataCount: $that.accountBankManageInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddAccountBankModal: function () {
                vc.emit('addAccountBank', 'openAddAccountBankModal', {});
            },
            _openEditAccountBankModel: function (_accountBank) {
                vc.emit('editAccountBank', 'openEditAccountBankModal', _accountBank);
            },
            _openDeleteAccountBankModel: function (_accountBank) {
                vc.emit('deleteAccountBank', 'openDeleteAccountBankModal', _accountBank);
            },
            _queryAccountBankMethod: function () {
                $that._listAccountBanks(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.accountBankManageInfo.moreCondition) {
                    $that.accountBankManageInfo.moreCondition = false;
                } else {
                    $that.accountBankManageInfo.moreCondition = true;
                }
            },
            _goBack: function () {
                vc.goBack()
            }
        }
    });
})(window.vc);
